{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pythoncom"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Monikiers\n",
    "Monikers are used as the basis for linking in COM. A linked object contains a moniker that identifies its source. When the user activates the linked object to edit it, the moniker is bound; this loads the link source into memory.\n",
    "\n",
    "### CreateBindCtx\n",
    "A bind context is an object that stores information about a particular moniker-binding operation. A bind context is required as a parameter in many methods of the IMoniker interface and in certain functions related to monikers.\n",
    "\n",
    "### RunningObjectTable\n",
    "Manages access to the running object table (ROT), a globally accessible look-up table on each workstation. A workstation's ROT keeps track of those objects that can be identified by a moniker and that are currently running on the workstation. When a client tries to bind a moniker to an object, the moniker checks the ROT to see if the object is already running; this allows the moniker to bind to the current instance instead of loading a new one.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----------------------------------------------------------------------------------------------------\n",
      "!{000209FF-0000-0000-C000-000000000046}\n",
      "1733733718\n",
      "4\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "C:\\Users\\Alex\\AppData\\Roaming\\Microsoft\\Templates\\Normal.dotm\n",
      "-456404445\n",
      "2\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "!Personal-Monikers::FileSyncClient\n",
      "-41559043\n",
      "4\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "https://d.docs.live.net/8bc640c57cda25b6/Growth%20-%20Tutorial%20Videos/Lessons%20-%20Data%20Resources/Win32COM%20Notes.docx\n",
      "720142563\n",
      "2\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "!Personal-Monikers::ToastActivation\n",
      "-19398716\n",
      "4\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "!Personal-Monikers::SyncEngineStorageProviderHandlerProxy\n",
      "-1463211928\n",
      "4\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "!{372496B2-D5D9-49D1-8C06-828C7D6A8F91}\n",
      "-63890725\n",
      "4\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "!{000209FE-0000-0000-C000-000000000046}\n",
      "-1071259421\n",
      "4\n",
      "None\n",
      "----------------------------------------------------------------------------------------------------\n",
      "!Personal-Monikers::SyncEngineCOMServer\n",
      "1292722682\n",
      "4\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "# must be 0\n",
    "context = pythoncom.CreateBindCtx(0)\n",
    "\n",
    "# Get all the Running Objects\n",
    "running_coms = pythoncom.GetRunningObjectTable()\n",
    "\n",
    "# Creates an enumerator that can list the monikers of all the objects \n",
    "# currently registered in the Running Object Table (ROT).\n",
    "monikiers = running_coms.EnumRunning()\n",
    "\n",
    "# loop through all the monikiers returend\n",
    "for monikier in monikiers:\n",
    "    \n",
    "    print('-'*100)\n",
    "    \n",
    "    # Gets the display name, which is a user-readable representation of this moniker. \n",
    "    print(monikier.GetDisplayName(context, monikier))\n",
    "    \n",
    "    # Calculates a 32-bit integer using the internal state of the moniker. \n",
    "    print(monikier.Hash())\n",
    "    \n",
    "    # Indicates whether this moniker is of one of the system-supplied moniker classes. 4(MKSYS_ITEMMONIKER)\n",
    "    print(monikier.IsSystemMoniker())\n",
    "    \n",
    "    # Supplies an enumerator that can enumerate the components of a composite moniker. \n",
    "    print(monikier.Enum())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Constants for the IsSystemMoniker Method\n",
    "pythoncom.MKSYS_ANTIMONIKER\n",
    "pythoncom.MKSYS_CLASSMONIKER\n",
    "pythoncom.MKSYS_POINTERMONIKER\n",
    "pythoncom.MKSYS_ITEMMONIKER\n",
    "pythoncom.MKSYS_GENERICCOMPOSITE"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
